import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:full_display/common/qxp_color.dart';
import 'package:full_display/common/qxp_style.dart';
import 'package:full_display/page/montage/montage_provider.dart';
import 'package:full_display/unit/asset_utils/asset_utils.dart';
import 'package:full_display/unit/screen/screen_util1.dart';
import 'package:full_display/unit/screen/screen_utility.dart';
import 'package:provider/provider.dart';

class MSnchronizationWidget extends StatelessWidget {
  MSnchronizationWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [ChangeNotifierProvider(create: (_) => MontageProvider())],
      child: const MSnchronizationPage(),
    );
  }
}

class MSnchronizationPage extends StatefulWidget {
  const MSnchronizationPage({super.key});

  @override
  State<MSnchronizationPage> createState() => _MSnchronizationPageState();
}

class _MSnchronizationPageState extends State<MSnchronizationPage> {
  var _montageProvider = MontageProvider();
  @override
  Widget build(BuildContext context) {
    _montageProvider = context.watch<MontageProvider>();
    return Scaffold(
      backgroundColor: ColorPlate.background,
      appBar: AppBar(
        backgroundColor: ColorPlate.background,
        elevation: 0,
        title: const Text('同步'),
        leading: IconButton(
          icon: Image.asset(
              height: 20.0.H, width: 20.0.W, AssetUtils.getAsset2Image("back")),
          onPressed: () {
            Navigator.pop(context);
          },
        ),
      ),
      body: Container(
        padding:
            EdgeInsets.fromLTRB(10, 20, 10, ScreenUtil1.bottomBarHeight + 20),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Expanded(
              child: GridView.builder(
                padding: EdgeInsets.zero,
                scrollDirection: Axis.vertical,
                physics: const AlwaysScrollableScrollPhysics(),
                shrinkWrap: true,
                itemCount: _montageProvider.sycData.length,
                itemBuilder: (con, index) {
                  return Container(
                      child: Text(_montageProvider.sycData[index]));
                },
                gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 1,
                  crossAxisSpacing: 1,
                  mainAxisSpacing: 10,
                  //宽高比
                  childAspectRatio: 28 / 5,
                ),
              ),
            ),
            Container(
              height: 20.0.H,
            ),
            InkWell(
              onTap: () {},
              child: Container(
                height: 40.0.H,
                width: ScreenUtil1.screenWidth - 40.0.W,
                decoration: BoxDecoration(
                  gradient: const LinearGradient(
                      //渐变位置
                      begin: Alignment.topCenter, //右上
                      end: Alignment.bottomCenter, //左下
                      //渐变颜色[始点颜色, 结束颜色]
                      colors: [ColorPlate.app_blue, ColorPlate.sub_blue]),
                  borderRadius: BorderRadius.all(Radius.circular(20.0.H)),
                ),
                child: Center(
                  child: Text(
                    "确定",
                    style: StandardTextStyle.textWhite16BoldStyle,
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
